You can create list assertions for page lists on a rule to determine if either the expected result is anywhere in the list of results returned by the rule. Even if the order of results changes, the test will continue to work.
You can configure list assertions for page lists on a rule to apply assertions to all the results that are returned by the rule. Configure an ordered list assertion so that you do not have to manually input assertions for each result in the list.
If you have not saved the automated test case, configure the property assertion in the Expected results pane.
Open the PegaUnit test case if it is not already open and then click the Definition tab.
If the test case is open, click the Definition tab.
Complete one of the following actions:
To add a new assertion, click Add expected result at the bottom of the page.
Modify an existing assertion in the pane.
From the Assertion type list, select List.
For data transforms and activities, complete the following tasks:
In the Page field, enter the page that contains the properties you want to add or modify.
From the Page class list, select the class to which the page belongs.
From the Appearances list, complete one of the following tasks:
Select In ANY instance to determine if either the expected result is anywhere in the list of results returned by the rule.
Select In ALL Instances to apply assertions to all the results that are returned by the rule.
In the of object field, enter the path of the object with which the results are compared or counted against when the assertion runs. For example, when the assertion runs, you can compare its results with .pxResults, which contains the results that obtained from running a rule.
Optional: In the Filter field, enter a property and value on which to filter results or open the Expression Builder by clicking the Gear icon to provide an expression that is used to filter results. The list assertion applies only to the page list entries that are specified for this filter value.
Complete one of the following tasks:
Add a new property.
Click Add properties.
If you are adding properties for data pages, proceed to step 9.
If you are adding properties for data transforms and activities, complete the following tasks:
From the Thread list, select the thread that contains the page whose properties or pages you want to add.
In the Browse properties of field, select the page whose properties or pages you want to add.
Select the property or page that you want to add. You can search for a property or its value by entering text in the search bar and pressing Enter.
From the Comparator list, select the comparator that you want to use to compare the property with a specified value.
In the Value field, either enter a value with which to compare the property or open the Expression Builder by clicking the Gear icon to enter an expression that is used to provide the value.
Note: The Gear icon does not appear until after you have saved the rule form.
To add a comment, click the Add comment icon, enter a comment, and click OK.
If you are adding properties using the property panel, click Done.
Click Save in the rule form.
When you run the automated test case, the system searches for the specified properties in the page list. One of the following occurs:
If you selected In ANY Instance, the assertion passes if the all the properties in the set match the expected values in the page list. If all the properties do not match any of the values in the page list, the assertion does not pass.
If you selected In ALL instances, the assertion passes if the all the properties in the set match the expected values in every entry in the page list. If any of the properties do not match any entry in the page list, the assertion does not pass.